package presentation;

import java.awt.Adjustable;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.jms.JMSException;
import javax.swing.*;

import commucation.MessagesReceiver;

public class ControlCenterFrame extends JFrame{
	
	private static final long serialVersionUID = 862960466847268055L;

    private JTable messagesTable;
    private MessagesReceiver receiver = new MessagesReceiver();
    JScrollBar scrollBarVertical = new JScrollBar();
    JScrollBar scrollbarHorizontal = new JScrollBar(Adjustable.HORIZONTAL);
	ControlCenterFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(600, 400);
		this.setTitle("Mock Centre de Controle");
		
		scrollBarVertical.setPreferredSize(new Dimension(20, 200));
	    scrollbarHorizontal.setPreferredSize(new Dimension(200, 20));
	    
		this.setLayout(new GridLayout(0,1));
		
		messagesTable = new JTable(receiver.getListener().getMessages());

		getContentPane().add(new JScrollPane(messagesTable));
		 
		 messagesTable.add(scrollBarVertical);
		 messagesTable.add(scrollbarHorizontal);
		
		setVisible(true);
		try {
			receiver.listenOn("messagesTopic");
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String args[]) {
		new ControlCenterFrame();
		
		
	}
}
